#include "InterOpDocumentReference.h"
#include "common/constant.h"

AMCAX_EXCHANGE_NAMESPACE_BEGIN

namespace InterOp
{
    std::vector<std::shared_ptr<InterOpDocumentInstance>> InterOpDocumentReference::GetDirectChildInstances() const 
    {
        return childInstances_;
    }

    void InterOpDocumentReference::AddChildInstance(std::shared_ptr<InterOpDocumentInstance> childInstance)
    {
        childInstances_.push_back(childInstance);
    }

    void InterOpDocumentReference::RemoveChildInstance(std::shared_ptr<InterOpDocumentInstance> childInstance)
    {
        childInstances_.erase(std::remove(childInstances_.begin(), childInstances_.end(), childInstance), childInstances_.end());
    }

    bool InterOpDocumentReference::IsPart() const
    {
        return childInstances_.size() < 1;
    }

    std::string InterOpDocumentReference::GetName() const
    {
        return name_;
    }

    void InterOpDocumentReference::SetName(const std::string& name)
    {
        name_ = name;
    }

    unsigned int InterOpDocumentReference::GetId() const
    {
        return id_;
    }

    void InterOpDocumentReference::SetId(unsigned int id)
    {
        id_ = id;
    }

    bool InterOpDocumentReference::GetPartShape(AMCAX::TopoCompound &topoCompound) const
    {
        if(!IsPart())
        {
            return false;
        }
        topoCompound = partTopoCompound_;
        return true;
    }

    bool InterOpDocumentReference::SetPartShape(const AMCAX::TopoCompound& topoCompound)
        {
            if (!IsPart())
            {
                return false;
            }
            partTopoCompound_ = topoCompound;
            return true;
        }

        bool InterOpDocumentReference::GetPMIData() const
        {
            // TODO: need to implement.
            return false;
        }
}

AMCAX_EXCHANGE_NAMESPACE_END